﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PID.Demo
{
    public static class ParameterHelper
    {
        public static void SaveParameters(string filePath, Dictionary<string, object> pairs)
        {
            using (StreamWriter writer = new StreamWriter(filePath))
            {
                foreach (var item in pairs)
                {
                    string line = $"{item.Key}={item.Value}";
                    writer.WriteLine(line);
                }
            }
        }
        public static Dictionary<string, string> LoadParameters(string filePath)
        {
            var parameters = new Dictionary<string, string>();

            using (StreamReader reader = new StreamReader(filePath))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] parts = line.Split('=');
                    if (parts.Length == 2)
                    {
                        string paramName = parts[0].Trim();
                        string paramValue = parts[1].Trim();
                        parameters[paramName] = paramValue;
                    }
                }
            }

            return parameters;
        }
    }
}
